﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AlexandriaPressUserBusinessLayer;
using System.Data;

namespace AlexandriaPressWebsite.MasterPages.UserPages
{
    public partial class AuthorDetailsPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            UserBusinsessLayer business = new UserBusinsessLayer();
            DataTable author = business.displayAuthorView(business.displayAuthor(Request.QueryString["id"]));
            authorDetailsGridView1.DataSource = author;
            authorDetailsGridView1.DataBind();

            DataTable books = business.booksByAuthorView(business.booksByAuthor(Request.QueryString["id"]));
            booksByAuthorGridView1.DataSource = books;
            booksByAuthorGridView1.EmptyDataText = "There are no books by this author.";
            booksByAuthorGridView1.DataBind();
        }

        protected void allTitlesGridView1_OnPageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            UserBusinsessLayer business = new UserBusinsessLayer();
            booksByAuthorGridView1.PageIndex = e.NewPageIndex;
            booksByAuthorGridView1.DataSource = business.booksByAuthorView(business.booksByAuthor(Request.QueryString["id"]));
            booksByAuthorGridView1.DataBind();
        }
    }
}
